package org.jeecg.modules.noRoadLedger.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.jeecg.modules.noRoadLedger.entity.NoRoadLedger;
import org.jeecg.modules.noRoadLedger.mapper.NoRoadLedgerMapper;
import org.jeecg.modules.noRoadLedger.service.INoRoadLedgerService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: 非道路移动机械电子台账
 * @Author: jeecg-boot
 * @Date:   2024-07-24
 * @Version: V1.0
 */
@Service
public class NoRoadLedgerServiceImpl extends ServiceImpl<NoRoadLedgerMapper, NoRoadLedger> implements INoRoadLedgerService {

    @Override
    public NoRoadLedger getLastByRegistrationCode(String registrationCode) {
        LambdaQueryWrapper<NoRoadLedger> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(NoRoadLedger::getRegistrationCode, registrationCode);
        wrapper.isNull(NoRoadLedger::getExitTime);
        wrapper.orderByDesc(NoRoadLedger::getCreateTime);
        wrapper.last("limit 1");
        return baseMapper.selectOne(wrapper);
    }
}
